//
//  CourseCell.m
//  HTP
//
//  Created by admin on 15/11/4.
//  Copyright © 2015年 nit. All rights reserved.
//

#import "CourseCell.h"
#define PADDING 5
#define LABELH 20
@interface CourseCell()
@property (nonatomic,retain) UILabel *startTimeLbl;
@property (nonatomic,retain) UILabel *endTimeLbl;
@property (nonatomic,retain) UILabel *nameLbl;
@property (nonatomic,retain) UILabel *subLbl;

@property (nonatomic,retain) UIImageView *stateImg;

@property (nonatomic,retain) UIImageView *lineImg;
@end
@implementation CourseCell
-(void)_initUI{
    _startTimeLbl = [self getNormolLabel];
    _startTimeLbl.textAlignment = _TEXT_ALIGN_RIGHT;
    [self.contentView addSubview:_startTimeLbl];
    
    _endTimeLbl = [self getNormolLabel];
    _endTimeLbl.textColor = RGBCOLOR(120, 120, 120, 0.7);
    _endTimeLbl.textAlignment = _TEXT_ALIGN_RIGHT;
    [self.contentView addSubview:_endTimeLbl];
    
    _nameLbl = [self getNormolLabel];
    _nameLbl.textAlignment = _TEXT_ALIGN_LEFT;
    _nameLbl.font = UIFONTSYS(15);
    [self.contentView addSubview:_nameLbl];
    
    _subLbl = [self getNormolLabel];
    _subLbl.textAlignment = _TEXT_ALIGN_LEFT;
    _subLbl.font = UIFONTSYS(15);
    [self.contentView addSubview:_subLbl];
    
    
    _stateImg = [[UIImageView alloc] init];
    _stateImg.contentMode = UIViewContentModeScaleAspectFit;
    [self.contentView addSubview:_stateImg];
    
    UIImageView *lineImage = [[UIImageView alloc] initWithFrame:CGRectMake(ScreenWidth / 3.0 - 10, 0, 0.5, CELLHEIGHT)];
    lineImage.image = [UIImage imageNamed:@"line_h"];
    [self.contentView addSubview:lineImage];
    
    UIImageView *line_h = [[UIImageView alloc] initWithFrame:CGRectMake(0, CELLHEIGHT - 1, ScreenWidth, 1)];
    line_h.image = [UIImage imageNamed:@"line_h"];
    [self.contentView addSubview:line_h];
    
    _lineImg = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"line_h"]];
    _lineImg.frame = CGRectMake(0, 0, ScreenWidth, 1);
    [self.contentView addSubview:_lineImg];
}
-(void)layoutSubviews{
    [_startTimeLbl setFrame:CGRectMake(0, PADDING*2, ScreenWidth / 3.0 - 10-10, LABELH)];
    
    [_endTimeLbl setFrame:CGRectMake(0, CGRectGetMaxY(_startTimeLbl.frame), ScreenWidth / 3.0 - 10 -10 , LABELH)];
    
    [_subLbl setFrame:CGRectMake(ScreenWidth / 3.0 , PADDING*2, ScreenWidth / 3.0 * 2.0 - 100, LABELH)];

    [_nameLbl setFrame:CGRectMake(ScreenWidth / 3.0 , CGRectGetMaxY(_subLbl.frame), ScreenWidth / 3.0 * 2.0 - 100, LABELH)];
    
    [_stateImg setFrame:CGRectMake(ScreenWidth - 80, CGRectGetMaxY(_subLbl.frame)-PADDING*1.5, 80, 20)];
}
-(void)setFirstImg:(NSInteger)row{
    if (row == 0) {
        if (_lineImg.superview) {
            return;
        }else{
            [self.contentView addSubview:_lineImg];
        }
    }else{
        if (_lineImg.superview) {
            [_lineImg removeFromSuperview];
        }else{
            return;
        }
    }
}
-(UILabel *)getNormolLabel{
    UILabel *label = [[UILabel alloc] init];
    label.textAlignment = _TEXT_ALIGN_CENTER;
    label.font = [UIFont systemFontOfSize:15];
    label.textColor = RGBCOLOR(0, 0, 0, 0.7);
    return label;
}
-(void)setCellData:(id)cellData{
    _startTimeLbl.text = @"14:00";
    _endTimeLbl.text   = @"18:00";
    [_subLbl setText:@"科目: 英语"];
    [_nameLbl setText:@"教师: 青苗家教"];
    [_stateImg setImage:[UIImage imageNamed:@"weipingjia"]];
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
